<?php
/**
 * 初始页
 *
 * @author chenfenghua <843958575@qq.com>
 * version 2.0
 */

namespace app\backend\modules\admin\models;

use Yii;
use app\backend\components\BaseModel;
use app\models\base\Project;
use app\models\base\User;

class AppAdmin extends BaseModel
{

	/**
	 * 初始页查询统计
	 * @return [type] [description]
	 */
    public static function getbasic()
    {
		$value = 0;
	    $gold = 0;
	    $cost = 0;
        $expect_cost = 0;
	    $member_count = 0;
        $surplus_value = 0;
        $surplus_gold = 0;
	    //查总价值。。。
    	$model = Project::find()->all();
    	foreach($model as $v){
    		$value += $v['all_value'];
    		$gold += $v['all_gold'];
    		$cost += $v['all_cost'];
            $expect_cost += $v['expected_cost'];
            $surplus_value += $v['surplus_value'];
            $surplus_gold += $v['surplus_gold'];
    	}
    	//查总成员数
    	$member_count = User::find()->where(['disabled'=>0])->count();
    	return [$value,$gold,$cost,$member_count,$expect_cost,$surplus_value,$surplus_gold];
    }
}